/* ─── Fonts ─────────────────────────────────────────────────────────────────
   Noto Serif    → Display / Headlines  (DESIGN.md §3)
   Work Sans     → Body / Titles        (DESIGN.md §3)
   Space Grotesk → Labels / Metadata    (DESIGN.md §3)
──────────────────────────────────────────────────────────────────────────── */
/* Fontes carregadas de forma assíncrona via <link> no index.html (#14) */

/* ─── Design Tokens (DESIGN.md §2) ──────────────────────────────────────────
   surface              : #0a1e30  Dark Navy base
   surface-container-low: #112f4e  Navy
   surface-container    : #3a1f1a  Dark Wood
   surface-container-high:#472f2b  Wood
   primary              : #e3c199  Beige/Tan
   primary-dark         : #c49642
   ghost-border         : rgba(227,193,153,0.15)
──────────────────────────────────────────────────────────────────────────── */

:root {
  --surface: #0a1e30;
  --surface-container-low: #112f4e;
  --surface-container: #3a1f1a;
  --surface-container-high: #472f2b;
  --surface-deep: #0a1e30;
  --primary: #e3c199;
  --primary-dark: #c49642;
  --on-primary: #210e0b;
  --on-surface: #e3c199;
  --on-surface-variant: rgba(227, 193, 153, 0.55);
  --on-surface-muted: rgba(227, 193, 153, 0.32);
  --ghost-border: rgba(227, 193, 153, 0.15);
  --outline-variant: rgba(227, 193, 153, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  min-height: 100%;
}

/* ─── Skip Link (eMAG §1) ────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--primary);
  color: var(--on-primary);
  padding: 8px 16px;
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 6px 6px;
  z-index: 200;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ─── Screen reader only ─────────────────────────────────────────────────── */
.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;
}

/* ─── Page Layout ─────────────────────────────────────────────────────────── */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  padding: 40px 16px 56px;
  font-family:
    "Work Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

/* ─── Institutional Header ────────────────────────────────────────────────── */
.inst-header {
  width: 100%;
  max-width: 800px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 28px 20px 26px;
  background: var(--surface-deep);
  border-bottom: 1px solid var(--outline-variant);
  border-radius: 12px 12px 0 0;
  position: relative;
  overflow: hidden;
}
/* Gold institutional accent stripe on left edge */
.inst-header::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #f0d698 0%, var(--primary-dark) 50%, #a07828 100%);
  border-radius: 12px 0 0 0;
}
.inst-logo {
  height: 48px;
  width: auto;
  flex-shrink: 0;
  opacity: 0.88;
  border-radius: 4px;
}
.inst-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.inst-organ {
  font-family: "Noto Serif", Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.03em;
  line-height: 1.2;
}
.inst-sector {
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 9px;
  font-weight: 500;
  color: rgba(227, 193, 153, 0.62);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* ─── Wrap — wooden surface behind briefcase ──────────────────────────────── */
.wrap {
  background: var(--surface-container-low);
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.06) 0px,
      rgba(0, 0, 0, 0.06) 1px,
      transparent 1px,
      transparent 32px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.05) 0px,
      rgba(0, 0, 0, 0.05) 1px,
      transparent 1px,
      transparent 32px
    );
  border-radius: 0;
  border-left: 1px solid var(--outline-variant);
  border-right: 1px solid var(--outline-variant);
  padding: 36px 24px 40px;
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow:
    0 40px 100px rgba(10, 30, 48, 0.75),
    0 4px 20px rgba(10, 30, 48, 0.5);
}

/* ─── Scene / 3D Container ────────────────────────────────────────────────── */
.scene {
  width: 100%;
  max-width: 720px;
  perspective: 1100px;
  position: relative;
  transform-style: preserve-3d;
}
.case-wrap {
  position: relative;
  width: 100%;
  transform-style: preserve-3d;
}

/* ─── Handle ──────────────────────────────────────────────────────────────── */
.handle-outer {
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 10;
}
.handle {
  width: 100px;
  height: 28px;
  background: linear-gradient(180deg, #5a3a2e 0%, #3e2418 40%, #4a2e1e 70%, #3a2218 100%);
  border: 2px solid rgba(227, 193, 153, 0.2);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  position: relative;
  box-shadow:
    inset 0 2px 6px rgba(255, 255, 255, 0.04),
    inset 0 -3px 8px rgba(0, 0, 0, 0.35),
    0 -2px 8px rgba(0, 0, 0, 0.3);
}
/* Grip line */
.handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 4px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Hide and collapse handle when lid is open */
.case-wrap:has(.lid.opened) .handle-outer {
  opacity: 0;
  max-height: 0;
  pointer-events: none;
  transition:
    opacity 0.3s ease 0.1s,
    max-height 0.01s ease 0.85s;
}
.handle-outer {
  max-height: 50px;
  overflow: hidden;
  transition:
    opacity 0.3s ease,
    max-height 0.01s ease;
}

/* ─── Lid ─────────────────────────────────────────────────────────────────── */
.lid {
  width: 100%;
  background: var(--surface-container);
  background-image: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.016) 0px,
    rgba(255, 255, 255, 0.016) 1px,
    transparent 1px,
    transparent 5px
  );
  border: 1px solid var(--ghost-border);
  border-top-color: rgba(227, 193, 153, 0.28); /* stronger top-edge highlight */
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 32px 0 26px;
  min-height: 130px;
  text-align: center;
  transform-origin: bottom center;
  transform: rotateX(0deg);
  max-height: 500px;
  overflow: hidden;
  transition:
    transform 0.85s cubic-bezier(0.32, 0, 0.15, 1),
    opacity 0.25s ease 0.55s,
    max-height 0.01s ease,
    min-height 0.01s ease,
    padding 0.01s ease;
  position: relative;
  z-index: 5;
  backface-visibility: hidden;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.04),
    /* inner top light */ inset 0 -6px 16px rgba(0, 0, 0, 0.22); /* inner bottom depth */
}
.lid.opened {
  transform: rotateX(118deg);
  opacity: 0;
  pointer-events: none;
  max-height: 0;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  transition:
    transform 0.85s cubic-bezier(0.32, 0, 0.15, 1),
    opacity 0.25s ease 0.55s,
    max-height 0.01s ease 0.85s,
    min-height 0.01s ease 0.85s,
    padding 0.01s ease 0.85s;
}
/* When closing: height/padding restore instantly, opacity returns, then lid rotates */
.lid:not(.opened) {
  transition:
    transform 0.7s cubic-bezier(0.32, 0, 0.15, 1) 0.05s,
    opacity 0.15s ease,
    max-height 0.01s ease,
    min-height 0.01s ease,
    padding 0.01s ease;
}

/* Inner corner reinforcement detail */
.lid::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  bottom: 0;
  border: 1px solid rgba(227, 193, 153, 0.06);
  border-radius: 8px 8px 0 0;
  pointer-events: none;
}

/* ─── Lid Typography ──────────────────────────────────────────────────────── */
/* Título centralizado dentro do .base (position: relative, sem 3D transforms) */
.lid-title {
  font-family: "Noto Serif", Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 5.5vw, 2.6rem);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.06em;
  line-height: 1.15;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 48px);
  text-align: center;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.lid-acervo {
  font-family:
    "Work Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: rgba(227, 193, 153, 0.58);
  letter-spacing: 0.06em;
  margin-top: 14px;
  padding: 0 32px;
  line-height: 1.7;
}

/* ─── Latch ───────────────────────────────────────────────────────────────── */
.lid-latch {
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  height: 24px;
  background: linear-gradient(180deg, #f0d698 0%, #d4a830 55%, #9e7620 100%);
  border-radius: 6px 6px 0 0;
  border: 1px solid rgba(227, 193, 153, 0.42);
  border-bottom: none;
  box-shadow:
    0 -3px 12px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -2px 4px rgba(0, 0, 0, 0.25);
  transition: filter 0.25s;
}
.lid-latch:hover {
  filter: brightness(1.1);
}
/* Latch shine strip */
.lid-latch::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 1px;
}
/* Latch keyhole */
.lid-latch::after {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  background: rgba(33, 14, 11, 0.5);
  border-radius: 50%;
  margin: 7px auto 0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* ─── Hinges ──────────────────────────────────────────────────────────────── */
.lid-hinges {
  position: absolute;
  bottom: -5px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 28px;
  pointer-events: none;
  z-index: 8;
}
.hinge {
  width: 28px;
  height: 14px;
  background: linear-gradient(180deg, #f0d698 0%, #d4a830 55%, #9e7620 100%);
  border-radius: 0 0 6px 6px;
  border: 1px solid rgba(227, 193, 153, 0.4);
  border-top: none;
  position: relative;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}
/* Hinge screw detail */
.hinge::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f4df94, #9e7620);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.55);
}

/* ─── Base / Briefcase Interior ───────────────────────────────────────────── */
.base {
  width: 100%;
  background: #2b1613;
  background-image: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.016) 0px,
    rgba(255, 255, 255, 0.016) 1px,
    transparent 1px,
    transparent 5px
  );
  border: 1px solid var(--ghost-border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  padding: 28px 24px 24px;
  position: relative;
  z-index: 4;
  min-height: 240px;
  box-shadow: inset 0 6px 20px rgba(0, 0, 0, 0.3); /* depth inside briefcase */
}

/* ─── Search Bar ─────────────────────────────────────────────────────────── */
.search-wrap {
  width: 100%;
  max-width: 600px;
  margin: 0 auto 18px;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition:
    opacity 0.3s,
    transform 0.3s;
}
.search-wrap.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.search-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ghost-border);
  color: var(--on-surface);
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  padding: 8px 4px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input::placeholder {
  color: rgba(227, 193, 153, 0.3);
  font-style: normal;
}
.search-input:focus {
  border-bottom-color: rgba(227, 193, 153, 0.45);
}

/* ─── Folders ─────────────────────────────────────────────────────────────── */
.folders-row {
  display: flex;
  gap: 14px;
  justify-content: center;
}

.folder {
  flex: 1;
  max-width: 124px;
  cursor: pointer;
  position: relative;
  opacity: 0;
  pointer-events: none;
  transform: translateY(28px);
  transition:
    opacity 0.38s,
    transform 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    filter 0.22s;
  touch-action: manipulation;
}
.folder.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.folder:hover {
  transform: translateY(-10px) !important;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55));
}
.folder:active {
  transform: translateY(-4px) !important;
}
.folder:hover .f-tab {
  transform: translateY(-4px) rotate(-2.5deg);
}
.folder:hover .f-paper {
  height: 22px;
  opacity: 1;
}
.folder:hover .f-paper2 {
  height: 30px;
  opacity: 0.65;
}

/* Tab */
.f-tab {
  width: 48%;
  height: 14px;
  border-radius: 6px 6px 0 0;
  margin-left: 10px;
  position: relative;
  z-index: 3;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* Papers peeking out */
.f-paper {
  position: absolute;
  bottom: calc(100% - 2px);
  left: 8%;
  right: 8%;
  height: 0;
  background: #f0e8cc;
  border-radius: 3px 3px 0 0;
  z-index: 1;
  opacity: 0;
  transition:
    height 0.22s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.22s;
}
.f-paper2 {
  position: absolute;
  bottom: calc(100% - 2px);
  left: 4%;
  right: 4%;
  height: 0;
  background: #e0d8b8;
  border-radius: 3px 3px 0 0;
  z-index: 0;
  opacity: 0;
  transition:
    height 0.28s 0.04s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.28s 0.04s;
}

/* Folder body */
.f-body {
  border-radius: 2px 8px 8px 8px;
  padding: 16px 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-height: 120px;
  justify-content: center;
  position: relative;
  z-index: 2;
  transition: filter 0.18s;
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.2),
    /* top inner depth */ inset 0 -1px 3px rgba(255, 255, 255, 0.07); /* subtle bottom light */
}
.folder:hover .f-body {
  filter: brightness(1.08);
}

/* Folder number */
.f-num {
  font-family: "Noto Serif", Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

/* Doc counter badge */
.f-count {
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 8px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.5);
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.13);
  padding: 2px 7px;
  border-radius: 10px;
  margin-top: 1px;
}

/* Folder label */
.f-name {
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  line-height: 1.5;
  min-height: 24px;
  color: rgba(227, 193, 153, 0.72);
  margin-top: 10px;
}

/* ─── Dimmed Folder (search no-match) ────────────────────────────────────── */
.folder--dimmed.visible {
  opacity: 0.2;
  pointer-events: none;
}

/* ─── Empty Folder State ──────────────────────────────────────────────────── */
.folder--empty.visible {
  opacity: 0.55;
}
.folder--empty:hover {
  opacity: 0.75;
}

.f-badge-soon {
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 7px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(0, 0, 0, 0.45);
  transform: rotate(-2deg);
  display: inline-block;
}

/* ─── Folder Colors — five muted tones with subtle gradients ─────────────────
   Tan / Muted Green / Light Brown / Grey-Brown / Pale Yellow
──────────────────────────────────────────────────────────────────────────── */
.c1 .f-tab {
  background: linear-gradient(180deg, #d4b47c 0%, #c09060 100%);
}
.c1 .f-body {
  background: linear-gradient(180deg, #dbb880 0%, #cca872 100%);
}
.c1 .f-num {
  color: #5c3c12;
}

.c2 .f-tab {
  background: linear-gradient(180deg, #9cb490 0%, #88a07c 100%);
}
.c2 .f-body {
  background: linear-gradient(180deg, #aac098 0%, #98ae86 100%);
}
.c2 .f-num {
  color: #344828;
}

.c3 .f-tab {
  background: linear-gradient(180deg, #bc9870 0%, #a88060 100%);
}
.c3 .f-body {
  background: linear-gradient(180deg, #c8a47e 0%, #b49070 100%);
}
.c3 .f-num {
  color: #543618;
}

.c4 .f-tab {
  background: linear-gradient(180deg, #a89888 0%, #948474 100%);
}
.c4 .f-body {
  background: linear-gradient(180deg, #b4a494 0%, #a09080 100%);
}
.c4 .f-num {
  color: #463830;
}

/* ─── Base Footer Stamp ───────────────────────────────────────────────────── */
.base-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 8px;
  font-weight: 500;
  color: rgba(227, 193, 153, 0.2);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* ─── Open / Close Button ─────────────────────────────────────────────────── */
.open-btn {
  display: block;
  margin: 28px auto 0;
  background: linear-gradient(160deg, #3e2218 0%, #2a1408 100%);
  border: 1px solid rgba(227, 193, 153, 0.32);
  color: var(--primary);
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  padding: 14px 44px;
  min-height: 48px;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.15s,
    transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.2s;
  position: relative;
  z-index: 10;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}
.open-btn:hover {
  background: linear-gradient(160deg, #4e2e20 0%, #381a0e 100%);
  border-color: rgba(227, 193, 153, 0.55);
  color: #f0e0b4;
  transform: translateY(-2px);
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
}
.open-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.open-btn:disabled {
  opacity: 0.3;
  cursor: default;
  transform: none !important;
}

/* ─── Body scroll lock when modal is open ────────────────────────────────── */
body.modal-open {
  overflow: hidden;
}

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 48, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--surface-deep);
  border: 1px solid rgba(227, 193, 153, 0.18);
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  margin: auto;
  position: relative;
  font-family:
    "Work Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow:
    0 0 80px rgba(10, 30, 48, 0.9),
    0 24px 60px rgba(10, 30, 48, 0.7);
  --folder-accent: var(--primary);
  opacity: 0;
  transform: scale(0.94) translateY(20px);
  transition:
    opacity 0.32s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.modal-overlay.open .modal-box {
  opacity: 1;
  transform: scale(1) translateY(0);
}
/* Colored top accent bar (set via JS custom property) */
.modal-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--folder-accent, var(--primary));
  border-radius: 12px 12px 0 0;
  pointer-events: none;
}

/* popIn animation replaced by .modal-box transition for smoother open/close */

.modal-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: rgba(227, 193, 153, 0.5);
  font-size: 15px;
  cursor: pointer;
  font-family: monospace;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  touch-action: manipulation;
  transition:
    color 0.15s,
    background 0.15s;
}
.modal-close-btn:hover {
  background: rgba(227, 193, 153, 0.08);
  color: var(--primary);
}

/* Modal header section */
.modal-header {
  padding: 24px 22px 0;
}
.modal-num {
  font-family: "Noto Serif", Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  padding-right: 40px; /* clear close button */
}
.modal-title-text {
  font-family: "Noto Serif", Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  padding-right: 40px;
  line-height: 1.35;
}

/* Ghost separator */
.modal-sep {
  border: none;
  border-top: 1px solid var(--outline-variant);
  margin: 16px 22px;
}

/* Document list */
#mContent {
  padding: 0 22px 22px;
}

.empty-msg {
  text-align: center;
  color: rgba(227, 193, 153, 0.3);
  font-size: 12px;
  padding: 28px 0;
  font-style: italic;
}

/* Doc item with left accent border */
.doc-item {
  padding: 14px 0 14px 14px;
  border-left: 2px solid var(--ghost-border);
  margin-bottom: 4px;
  transition: border-left-color 0.18s;
}
.doc-item:last-child {
  margin-bottom: 0;
}
.doc-item:hover {
  border-left-color: rgba(227, 193, 153, 0.45);
}

.doc-title {
  display: block;
  color: #d4ae78;
  font-family:
    "Work Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.45;
}

/* Action buttons row */
.doc-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.doc-btn {
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 7px 16px;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background 0.18s,
    border-color 0.18s,
    color 0.15s,
    transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.18s;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.doc-btn:hover {
  transform: translateY(-1px);
}
.doc-btn:active {
  transform: translateY(0);
}

/* Visualizar — primary gradient button */
.doc-btn--view {
  background: linear-gradient(160deg, #3e2218 0%, #2a1408 100%);
  border: 1px solid rgba(227, 193, 153, 0.32);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.doc-btn--view::before {
  content: "↗ ";
  font-size: 9px;
}
.doc-btn--view:hover {
  background: linear-gradient(160deg, #4e2e20 0%, #381a0e 100%);
  border-color: rgba(227, 193, 153, 0.55);
  color: #f0e0b4;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

/* Baixar — ghost/outline button */
.doc-btn--download {
  background: transparent;
  border: 1px solid var(--ghost-border);
  color: rgba(227, 193, 153, 0.6);
}
.doc-btn--download::before {
  content: "⤓ ";
  font-size: 11px;
}
.doc-btn--download:hover {
  border-color: rgba(227, 193, 153, 0.4);
  color: var(--primary);
  background: rgba(227, 193, 153, 0.05);
}

/* Focus visible for buttons */
.doc-btn:focus-visible {
  outline: 2px solid rgba(227, 193, 153, 0.65);
  outline-offset: 2px;
}

.doc-desc {
  color: var(--on-surface-variant);
  font-family:
    "Work Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: 12px;
  line-height: 1.6;
}

/* ─── Document Metadata (stamped style) ──────────────────────────────────── */
.doc-meta {
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 9px;
  font-weight: 500;
  color: rgba(227, 193, 153, 0.38);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
  transform: rotate(-0.5deg);
  transform-origin: left center;
}

/* ─── Copy Link Button (ghost style) ─────────────────────────────────────── */
.doc-btn--link {
  background: transparent;
  border: 1px solid var(--outline-variant);
  color: rgba(227, 193, 153, 0.45);
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    border-color 0.18s,
    color 0.15s;
  min-height: 32px;
}
.doc-btn--link:hover {
  border-color: rgba(227, 193, 153, 0.35);
  color: rgba(227, 193, 153, 0.75);
}

/* ─── Dimmed Doc Item (search no-match) ──────────────────────────────────── */
.doc-item--dimmed {
  opacity: 0.25;
}

/* ─── Page Footer ─────────────────────────────────────────────────────────── */
.page-footer {
  width: 100%;
  max-width: 800px;
  padding: 14px 28px;
  background: var(--surface-deep);
  border-top: 1px solid var(--outline-variant);
  border-radius: 0 0 12px 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 20px;
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 8px;
  font-weight: 400;
  color: var(--on-surface-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.page-footer span {
  line-height: 1.65;
}
.footer-link {
  color: rgba(227, 193, 153, 0.48);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-link:hover {
  color: rgba(227, 193, 153, 0.72);
}

/* ─── Focus Visible — keyboard nav (SKILL.md §1) ─────────────────────────── */
:focus {
  outline: none;
}

.open-btn:focus-visible,
.modal-close-btn:focus-visible {
  outline: 2px solid rgba(227, 193, 153, 0.65);
  outline-offset: 3px;
}
.folder:focus-visible {
  outline: 2px solid rgba(227, 193, 153, 0.65);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─── Reduced Motion (SKILL.md §7) ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .lid,
  .lid.opened,
  .lid:not(.opened) {
    transition: none;
  }
  .handle-outer,
  .case-wrap:has(.lid.opened) .handle-outer {
    transition: none;
  }
  .folder {
    transition:
      opacity 0.01ms,
      transform 0.01ms;
    filter: none !important;
  }
  .folder:hover {
    transform: none !important;
    filter: none !important;
  }
  .folder:hover .f-tab {
    transform: none;
  }
  .open-btn {
    transition: none;
    transform: none !important;
  }
  .modal-overlay {
    transition: none;
  }
  .modal-box {
    transition: none;
    transform: none;
  }
  .modal-overlay.open .modal-box {
    transform: none;
  }
  .toast {
    transition: none;
    transform: none;
  }
  .toast--visible {
    transform: none;
  }
  .shortcuts-popover {
    transition: none;
    transform: none;
  }
  .shortcuts-popover--visible {
    transform: none;
  }
}

/* ─── Responsive — Tablet ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  body {
    padding: 24px 12px 40px;
  }
  .inst-header {
    padding: 16px 20px 16px 22px;
    gap: 14px;
  }
  .inst-organ {
    font-size: 13px;
  }
  .wrap {
    padding: 28px 16px 32px;
  }
  .lid {
    padding: 26px 0 22px;
    min-height: 110px;
  }
  .lid-acervo {
    font-size: 10px;
    padding: 0 20px;
    margin-top: 10px;
  }
  .open-btn {
    margin-top: 22px;
    padding: 13px 36px;
    font-size: 10px;
  }
  .modal-box {
    max-width: 96%;
  }
}

/* ─── Responsive — Mobile (scroll-snap for 4 folders) ────────────────────── */
@media (max-width: 520px) {
  body {
    padding: 16px 10px 32px;
  }

  .scene {
    max-width: 100%;
  }

  .inst-header {
    border-radius: 8px 8px 0 0;
    padding: 14px 16px 14px 20px;
    gap: 12px;
  }
  .inst-organ {
    font-size: 12px;
  }
  .inst-sector {
    font-size: 9px;
  }

  .wrap {
    padding: 20px 12px 24px;
    max-width: 100%;
    overflow: hidden;
  }
  .lid {
    padding: 22px 0 18px;
    min-height: 90px;
  }
  .lid-acervo {
    font-size: 9px;
    padding: 0 14px;
    margin-top: 8px;
  }

  /* Horizontal scroll with snap for 4 folders (only when briefcase is open) */
  .folders-row {
    flex-wrap: nowrap;
    overflow-x: hidden;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-bottom: 10px;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(227, 193, 153, 0.2) transparent;
  }
  /* When open: enable horizontal scroll for folders */
  .case-wrap:has(.lid.opened) .folders-row {
    overflow-x: auto;
    max-height: none;
    padding-bottom: 10px;
  }
  /* When closed: collapse folders-row to eliminate wasted vertical space */
  .case-wrap:not(:has(.lid.opened)) .folders-row {
    max-height: 0;
    padding-bottom: 0;
    overflow: hidden;
  }
  .folders-row::-webkit-scrollbar {
    height: 3px;
  }
  .folders-row::-webkit-scrollbar-track {
    background: transparent;
  }
  .folders-row::-webkit-scrollbar-thumb {
    background: rgba(227, 193, 153, 0.25);
    border-radius: 2px;
  }
  .folders-row::after {
    content: "";
    flex: 0 0 1px;
  }
  .folder {
    flex: 0 0 100px;
    max-width: 100px;
    scroll-snap-align: start;
  }
  .f-body {
    min-height: 92px;
    padding: 12px 6px 12px;
  }
  .f-num {
    font-size: 26px;
  }
  .f-name {
    font-size: 7px;
    letter-spacing: 0.07em;
    min-height: 20px;
    margin-top: 6px;
  }
  .f-tab {
    height: 12px;
  }

  .base {
    padding: 20px 12px 18px;
    min-height: 120px;
  }

  .modal-header {
    padding: 20px 18px 0;
  }
  .modal-sep {
    margin: 14px 18px;
  }
  #mContent {
    padding: 0 18px 18px;
  }
  .modal-num {
    font-size: 18px;
  }
  .modal-title-text {
    font-size: 14px;
  }
  .modal-box {
    border-radius: 10px;
    max-height: 88vh;
  }

  .open-btn {
    margin-top: 16px;
    padding: 12px 26px;
    font-size: 10px;
  }
  .page-footer {
    flex-direction: column;
    gap: 5px;
    padding: 10px 16px;
    font-size: 9px;
    border-radius: 0 0 8px 8px;
  }
  .doc-btn {
    min-height: 44px;
  }
}

/* ─── Toast Notifications (#3) ───────────────────────────────────────────── */
#toastContainer {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(43, 22, 19, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--ghost-border);
  color: var(--primary);
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 10px 22px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.28s,
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}
.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Search "No Results" Message (#4) ──────────────────────────────────── */
.search-no-results {
  color: rgba(227, 193, 153, 0.45);
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 10px 0 2px;
  font-style: italic;
}

/* ─── Install App Button (PWA #1) ───────────────────────────────────────── */
.install-btn {
  background: transparent;
  border: 1px solid var(--ghost-border);
  color: rgba(227, 193, 153, 0.48);
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    border-color 0.18s,
    color 0.15s;
}
.install-btn:hover {
  border-color: rgba(227, 193, 153, 0.4);
  color: rgba(227, 193, 153, 0.72);
}

/* ─── Keyboard Shortcuts Popover (#7) ────────────────────────────────────── */
.shortcuts-popover {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 250;
  background: rgba(43, 22, 19, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--ghost-border);
  border-radius: 10px;
  padding: 18px 22px 14px;
  min-width: 240px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.22s,
    transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.shortcuts-popover--visible {
  opacity: 1;
  transform: translateY(0);
}
.shortcuts-title {
  font-family: "Noto Serif", Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}
.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.shortcut-row dt {
  display: flex;
  gap: 4px;
  align-items: center;
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 10px;
  color: var(--on-surface-variant);
}
.shortcut-row dd {
  font-family:
    "Work Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: 11px;
  color: rgba(227, 193, 153, 0.65);
  text-align: right;
}
.shortcuts-popover kbd {
  display: inline-block;
  background: rgba(227, 193, 153, 0.1);
  border: 1px solid rgba(227, 193, 153, 0.2);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.6;
}
.shortcuts-close {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: rgba(227, 193, 153, 0.4);
  font-size: 12px;
  cursor: pointer;
  font-family: monospace;
  min-width: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
}
.shortcuts-close:hover {
  color: var(--primary);
}

/* ─── Print Index Button (#6) ────────────────────────────────────────────── */
.print-index-btn {
  background: transparent;
  border: 1px solid var(--ghost-border);
  color: rgba(227, 193, 153, 0.48);
  font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    border-color 0.18s,
    color 0.15s;
}
.print-index-btn:hover {
  border-color: rgba(227, 193, 153, 0.4);
  color: rgba(227, 193, 153, 0.72);
}

/* Hide print index on screen */
#printIndex {
  display: none;
}

/* ─── Print View (#9) — clean index for administrative processes ─────────── */
@media print {
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body {
    background: #fff !important;
    color: #210e0b !important;
    padding: 20px !important;
    display: block !important;
  }

  /* Hide UI chrome */
  .skip-link,
  .sr-only,
  .handle-outer,
  .lid,
  .lid-latch,
  .lid-hinges,
  .open-btn,
  .modal-overlay,
  .search-wrap,
  .f-paper,
  .f-paper2,
  .f-tab,
  #toastContainer,
  .install-btn,
  .print-index-btn,
  .folders-row,
  .shortcuts-popover {
    display: none !important;
  }

  .inst-header {
    background: none !important;
    border: none !important;
    padding: 0 0 12px !important;
    border-bottom: 2px solid #210e0b !important;
    border-radius: 0 !important;
    max-width: 100% !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .inst-header::before {
    display: none !important;
  }
  .inst-organ {
    color: #210e0b !important;
    font-size: 16px !important;
  }
  .inst-sector {
    color: #555 !important;
    font-size: 10px !important;
  }

  .wrap {
    background: none !important;
    border: none !important;
    padding: 16px 0 !important;
    max-width: 100% !important;
    box-shadow: none !important;
  }

  .scene {
    perspective: none !important;
    max-width: 100% !important;
  }
  .case-wrap {
    overflow: visible !important;
  }

  .base {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    min-height: auto !important;
  }

  .folders-row {
    flex-wrap: wrap !important;
    gap: 20px !important;
    justify-content: flex-start !important;
  }

  .folder {
    opacity: 1 !important;
    transform: none !important;
    flex: 0 0 auto !important;
    max-width: 100% !important;
    width: 100% !important;
    page-break-inside: avoid;
    break-inside: avoid;
    border-bottom: 1px solid #ccc;
    padding-bottom: 12px;
    margin-bottom: 4px;
  }
  .folder--empty.visible {
    opacity: 0.6 !important;
  }

  .f-body {
    background: none !important;
    padding: 4px 0 !important;
    min-height: auto !important;
    flex-direction: row !important;
    gap: 8px !important;
    justify-content: flex-start !important;
  }
  .f-num {
    font-size: 16px !important;
    color: #210e0b !important;
  }
  .f-count {
    background: none !important;
    color: #666 !important;
    font-size: 10px !important;
    padding: 0 !important;
  }
  .f-name {
    color: #210e0b !important;
    font-size: 12px !important;
    margin-top: 2px !important;
    text-align: left !important;
  }

  .base-footer {
    display: none !important;
  }

  .page-footer {
    background: none !important;
    border-top: 1px solid #ccc !important;
    border-radius: 0 !important;
    color: #666 !important;
    max-width: 100% !important;
    padding: 8px 0 !important;
  }
  .footer-link {
    color: #333 !important;
  }

  /* ─── Print Index (#6) ─────────────────────────────────────────────────── */
  #printIndex {
    display: block !important;
    page-break-before: avoid;
    margin-top: 24px;
  }
  .print-index-title {
    font-family: "Noto Serif", Georgia, "Times New Roman", serif;
    font-size: 18px;
    font-weight: 700;
    color: #210e0b;
    margin-bottom: 4px;
  }
  .print-index-date {
    font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
    font-size: 10px;
    color: #666;
    margin-bottom: 20px;
  }
  .print-folder-section {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 18px;
  }
  .print-folder-name {
    font-family: "Noto Serif", Georgia, "Times New Roman", serif;
    font-size: 13px;
    font-weight: 700;
    color: #210e0b;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4px;
    margin-bottom: 8px;
  }
  .print-doc-table {
    width: 100%;
    border-collapse: collapse;
    font-family:
      "Work Sans",
      system-ui,
      -apple-system,
      "Segoe UI",
      sans-serif;
    font-size: 10px;
    color: #333;
  }
  .print-doc-table th {
    text-align: left;
    font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #666;
    border-bottom: 1px solid #999;
    padding: 4px 6px;
  }
  .print-doc-table td {
    padding: 5px 6px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    line-height: 1.4;
  }
  .print-doc-table tr:last-child td {
    border-bottom: none;
  }
  .print-path {
    font-family: "Space Grotesk", "Segoe UI", Roboto, sans-serif;
    font-size: 8px;
    color: #888;
    word-break: break-all;
  }
  .print-empty {
    font-style: italic;
    color: #999;
  }
}
