/* Senfio OTA. Paleta tirada de uma placa: azul de máscara de solda, âmbar de
   cobre exposto, serigrafia clara. Os azuis têm a mesma luminosidade e o
   mesmo croma (OKLCH) do verde original, só o matiz mudou. Sem fontes
   externas: o app roda fechado. */
:root {
  --board: #f1f4f8;
  --surface: #ffffff;
  --ink: #1a212b;
  --muted: #5f6772;
  --line: #d5dae1;
  --field-line: #8e96a1;
  --mask: #395a8b;
  --mask-deep: #283f62;
  --row-hover: #f6f8fb;
  --head-bg: #f8fafb;
  --copper: #a35f0c;
  --danger: #a4271d;
  --ok-bg: #e5eef9;
  --error-bg: #fbe9e6;
  --warn-bg: #fdf3e3;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--board); color: var(--ink); }

body {
  margin: 0;
  font: 1rem/1.5 var(--sans);
}

a { color: var(--mask-deep); text-underline-offset: 0.18em; }
a:hover { color: var(--mask); }

:focus-visible {
  outline: 3px solid var(--copper);
  outline-offset: 2px;
  border-radius: 2px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Barra superior */
.bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem clamp(1rem, 4vw, 2.5rem);
  background: var(--mask-deep);
  color: #fff;
}
.bar a { color: #fff; text-decoration: none; }
.bar a:hover { text-decoration: underline; }
.brand { font-weight: 700; letter-spacing: 0.01em; }
.bar nav { display: flex; gap: 1.1rem; }
.who {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 0 auto;
  font-size: 0.9rem;
}
.who span { opacity: 0.85; }

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2.5rem) 4rem;
}

h1 {
  margin: 0 0 1.25rem;
  font-size: 1.6rem;
  line-height: 1.25;
}

/* O caminho é o título da página: é o mesmo endereço que a tag usa. A linha
   embaixo é a trilha da placa, terminada numa via. */
.path {
  position: relative;
  padding-bottom: 0.9rem;
  margin-bottom: 1.6rem;
  font-family: var(--mono);
  font-size: clamp(1.25rem, 3.2vw, 1.9rem);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.path::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: min(100%, 22rem);
  height: 3px;
  background: var(--mask);
}
.path::before {
  content: "";
  position: absolute;
  left: min(100%, 22rem);
  bottom: -4px;
  width: 11px;
  height: 11px;
  margin-left: -1px;
  border: 3px solid var(--mask);
  border-radius: 50%;
  background: var(--board);
}
.path .seg { color: var(--ink); text-decoration: none; }
.path a.seg:hover { color: var(--mask); text-decoration: underline; }
.path .sep { color: var(--copper); padding: 0 0.08em; }

.note { color: var(--muted); font-size: 0.9rem; margin: 0.4rem 0 0; }

/* Botões */
button, .button {
  display: inline-block;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--board); color: var(--ink); }
.primary { background: var(--mask); border-color: var(--mask); color: #fff; }
.primary:hover { background: var(--mask-deep); border-color: var(--mask-deep); color: #fff; }
.destructive { background: var(--danger); border-color: var(--danger); color: #fff; }
.destructive:hover { background: #7f1c14; border-color: #7f1c14; color: #fff; }
.quiet {
  padding: 0.25rem 0.6rem;
  border-color: rgba(255, 255, 255, 0.55);
  background: transparent;
  color: #fff;
  font-weight: 500;
}
.quiet:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

/* Avisos */
.flash {
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  border-left: 5px solid var(--mask);
  background: var(--ok-bg);
}
.flash p { margin: 0; }
.flash p + p { margin-top: 0.25rem; }
.flash-error { border-left-color: var(--danger); background: var(--error-bg); }

/* Entrada: cartão centralizado na tela, com a arte à esquerda. */
.bare main {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}
.bare .flash { width: min(52rem, 100%); }
.entry {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  width: min(52rem, 100%);
  min-height: 24rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(26, 33, 43, 0.14);
}
.entry-art { background: var(--mask-deep); }
.art { display: block; width: 100%; height: 100%; }
.entry-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: clamp(1.75rem, 5vw, 3rem);
}
.entry-body p { margin: 0; }
.entry-body h1 { margin: 0; font-size: clamp(1.6rem, 3.5vw, 2.1rem); }
.entry-brand { color: var(--mask); font-weight: 700; }
.entry-action { justify-self: start; align-self: flex-start; margin-top: 0.5rem; padding: 0.65rem 1.2rem; }

/* Formulários */
.field { display: grid; gap: 0.3rem; }
.field > span { font-weight: 600; font-size: 0.9rem; }
.check { display: flex; align-items: center; gap: 0.45rem; }
button:disabled, button:disabled:hover {
  border-color: var(--line);
  background: var(--head-bg);
  color: var(--muted);
  cursor: not-allowed;
}

/* Barra acima da listagem: contagem à esquerda, ações à direita. */
.listbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0 0 0.75rem;
}
.listbar .count { margin: 0; color: var(--muted); font-size: 0.92rem; }

input[type="text"], input[type="file"], textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--field-line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
input[type="file"] { padding: 0.35rem; }
textarea { font-family: var(--mono); font-size: 0.95rem; line-height: 1.45; resize: vertical; }
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--mask); }

/* Listagem */
.listing {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
}
.listing th, .listing td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: baseline;
}
.listing thead th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--head-bg);
}
.listing tbody tr:last-child td { border-bottom: 0; }
.listing tbody tr:hover { background: var(--row-hover); }
.listing .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.listing .when { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.listing .name { font-weight: 600; overflow-wrap: anywhere; }
.listing .name a { text-decoration: none; }
.listing .name a:hover { text-decoration: underline; }
.listing .dir { color: var(--copper); }
.listing .dir:hover { color: #7c4707; }
.listing .hash { max-width: 11rem; }
.listing .ops { white-space: nowrap; }
.ops-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.35rem; }

/* Ações da linha: botões compactos, para não competir com o nome. */
.op {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}
.op:hover { border-color: var(--mask); background: var(--board); color: var(--mask-deep); }
.op.danger { color: var(--danger); }
.op.danger:hover { border-color: var(--danger); background: var(--error-bg); color: var(--danger); }

/* Botão de ícone ao lado do nome do arquivo. */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  margin-left: 0.2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  vertical-align: middle;
}
.icon:hover { border-color: var(--line); background: var(--board); color: var(--mask-deep); }
.ico { width: 1rem; height: 1rem; }
.listing .empty { padding: 2rem 1rem; color: var(--muted); text-align: center; }
.listing .up td { background: var(--head-bg); font-size: 0.92rem; }
.listing .detail { font-size: 0.88rem; color: var(--muted); overflow-wrap: anywhere; }
.history { margin-top: 1.25rem; }
.history .name { min-width: 15rem; font-weight: 500; }

.copy {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: 0.82rem var(--mono);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy:hover { background: none; color: var(--ink); text-decoration: underline; }

/* Aviso de que algo foi copiado. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 10;
  padding: 0.55rem 1rem;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.5rem);
  transition: opacity 0.15s, transform 0.15s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Aviso fixo no topo de uma página. */
.notice {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 5px solid var(--copper);
  background: var(--warn-bg);
  font-size: 0.92rem;
}
.notice p { margin: 0; }
.notice p + p { margin-top: 0.35rem; }

/* Telas de uma ação só */
.gate { max-width: 34rem; }
.gate.wide { max-width: 48rem; }
.gate p { margin: 0 0 1rem; }
.target {
  padding: 0.55rem 0.75rem;
  border-left: 5px solid var(--copper);
  background: var(--surface);
  font-family: var(--mono);
  overflow-wrap: anywhere;
}
.target-inline { font-family: var(--mono); font-weight: 600; overflow-wrap: anywhere; }
.stack { display: grid; gap: 1.1rem; margin: 1.25rem 0 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }

/* Visualizador de texto. */
.viewer {
  margin: 1.25rem 0 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font: 0.92rem/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  max-height: 70vh;
  tab-size: 4;
}
.empty-file { color: var(--muted); font-family: var(--sans); }

/* Modais. */
.modal {
  width: min(28rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(26, 33, 43, 0.22);
}
.modal.wide { width: min(40rem, calc(100vw - 2rem)); }
.modal::backdrop { background: rgba(26, 33, 43, 0.5); }
.modal .stack { margin: 0; }
.modal h2 { margin: 0; font-size: 1.3rem; }
.modal p { margin: 0; }
.note.warn { color: #7c4707; font-weight: 600; }

/* Prévia do envio: um item por arquivo escolhido. */
.plan {
  display: grid;
  gap: 0.4rem;
  max-height: 16rem;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}
.plan-item {
  padding: 0.45rem 0.65rem;
  border-left: 4px solid var(--mask);
  background: var(--board);
}
.plan-head { display: flex; justify-content: space-between; gap: 1rem; }
.plan-path { font-family: var(--mono); font-size: 0.9rem; font-weight: 600; overflow-wrap: anywhere; }
.plan-size { flex: none; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.plan-state { display: block; font-size: 0.85rem; color: var(--muted); }
.plan-item.replace { border-left-color: var(--copper); }
.plan-item.replace .plan-state { color: #7c4707; }
.plan-item.conflict, .plan-item.blocked { border-left-color: var(--danger); background: var(--error-bg); }
.plan-item.conflict .plan-state, .plan-item.blocked .plan-state { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

@media (max-width: 52rem) {
  .listing .hash, .listing th.hash { display: none; }
}
@media (max-width: 44rem) {
  .entry { grid-template-columns: minmax(0, 1fr); }
  .entry-art { height: 13rem; }
}
@media (max-width: 36rem) {
  .bar { flex-wrap: wrap; gap: 0.5rem 1.2rem; }
  .who { margin-left: 0; flex-basis: 100%; }

  /* Em tela estreita cada linha vira um bloco: nome e tamanho em cima, ações
     embaixo. */
  .listing thead { display: none; }
  .listing tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.2rem 0.75rem;
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--line);
  }
  .listing tbody tr:last-child { border-bottom: 0; }
  .listing td { padding: 0; border: 0; }
  .listing .when, .listing .hash { display: none; }
  .listing .ops { grid-column: 1 / -1; white-space: normal; }
  .ops-row { justify-content: flex-start; margin-top: 0.25rem; }
  .listing .up td, .listing .empty { grid-column: 1 / -1; }

  .history tr { display: block; }
  .history td { display: block; }
  .history .when { display: block; font-size: 0.85rem; }
  .history .name { min-width: 0; }
}
