@font-face {
  font-family: Figtree;
  src: url("/fonts/figtree-latin.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --night: #0f1115;
  --slate: #8a847e;
  --accent: #ff4d5a;
  --accent-2: #ff7a5c;
  --accent-grad: linear-gradient(135deg, #ff4d5a, #ff7a5c);
  --accent-ink: #bf2436;
  --on-accent: #0f1115;
  --surface: #ffffff;
  --line-2: #d9d0c8;
  --ink: #1a1614;
  --ink-2: #4a433e;
  --bad: #b4202f;
  --shadow-2: 0 2px 6px rgba(15, 17, 21, .07), 0 16px 40px rgba(15, 17, 21, .16);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Figtree, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(980px 520px at 50% -120px, rgba(255, 122, 92, .22), transparent 62%),
    radial-gradient(720px 420px at 100% 110%, rgba(255, 77, 90, .08), transparent 55%),
    #f3efe9;
}

button, input, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 3px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 16px 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(560px, 100%);
}

.toolbar[hidden] { display: none; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .6);
  box-shadow: inset 0 0 0 1px rgba(217, 208, 200, .9);
}

.tabs[hidden] { display: none; }

.tabs a {
  padding: 7px 18px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 620;
  text-decoration: none;
}

.tabs a:hover { color: var(--ink); }

.tabs a[aria-current="page"] {
  background: var(--night);
  color: #fff;
}

.form-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
}

select {
  width: 100%;
  height: 43px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 16px;
  font-weight: 450;
}

select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.groups:has(.client) {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 470px), 1fr));
  gap: 22px;
}

.group.client {
  padding: 20px 14px 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .5);
  box-shadow: inset 0 0 0 1px rgba(217, 208, 200, .7);
}

.group.client h2 {
  color: var(--ink);
  font-size: 15px;
  letter-spacing: -0.01em;
  text-transform: none;
}

.group.client .library { gap: 24px 6px; flex-wrap: nowrap; }
.group.client .app { width: 104px; }
.group.client .glyph { width: 76px; height: 76px; border-radius: 22px; }
.group.client .glyph svg { width: 36px; height: 36px; }
.group.client .name { font-size: 12.5px; }
.groups:has(.client) .add-row { grid-column: 1 / -1; }

/* Arrastar e soltar */
.app[data-id] {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body.arranging {
  cursor: grabbing;
  -webkit-user-select: none;
  user-select: none;
}

body.arranging .bubble,
body.arranging .edit { display: none; }

body.arranging .app[data-id] .glyph {
  animation: wiggle .26s ease-in-out infinite alternate;
}

body.arranging .app[data-id]:nth-child(2n) .glyph { animation-delay: -.13s; }

@keyframes wiggle {
  from { transform: rotate(-1.8deg); }
  to { transform: rotate(1.8deg); }
}

.app.placeholder { opacity: .22; }
.app.placeholder .dot { display: none; }

.ghost {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  margin: 0;
  pointer-events: none;
  will-change: transform;
}

.ghost .glyph {
  transform: scale(1.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .45),
    0 24px 44px rgba(40, 24, 18, .32);
}

.ghost .bubble,
.ghost .edit { display: none; }

.group { border-radius: 18px; transition: background .15s ease, box-shadow .15s ease; }

body.arranging .group.drop-target {
  background: rgba(255, 255, 255, .6);
  box-shadow: inset 0 0 0 2px rgba(255, 77, 90, .45);
}


.toast {
  position: fixed;
  z-index: 1100;
  bottom: 22px;
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--night);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-2);
  transform: translateX(-50%);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.search svg {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--slate);
  pointer-events: none;
}

.search input {
  height: 40px;
  padding: 0 34px 0 38px;
  border-radius: 999px;
  border-color: rgba(217, 208, 200, .9);
  background: rgba(255, 255, 255, .72);
  font-size: 15px;
}

.search kbd {
  position: absolute;
  right: 12px;
  padding: 1px 6px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  color: var(--slate);
  font: 600 11px/1.4 Figtree, sans-serif;
  pointer-events: none;
}

.search input:focus + kbd,
.search input:not(:placeholder-shown) + kbd { display: none; }

.menu { display: flex; gap: 6px; }

.chip {
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 0 0 1px rgba(217, 208, 200, .9);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 620;
  cursor: pointer;
}

.chip:hover { background: #fff; color: var(--ink); }

.groups {
  display: grid;
  gap: 38px;
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 80px;
}

.group h2 {
  margin: 0 0 18px;
  color: var(--slate);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}

.login {
  display: grid;
  place-items: center;
  width: 100%;
  padding: 40px 16px 80px;
}

.login[hidden] { display: none; }

.login-card {
  width: min(380px, 100%);
  padding: 28px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow-2);
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.login-sub {
  margin: -6px 0 4px;
  color: var(--ink-2);
  font-size: 14px;
}

.btn.wide { width: 100%; padding: 12px 14px; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.brand img { display: block; }

.library-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.library {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  align-items: flex-start;
  gap: 32px 22px;
}

.glyph-wrap {
  position: relative;
  display: block;
}

.dot {
  position: absolute;
  z-index: 4;
  right: 2px;
  bottom: 2px;
  width: 15px;
  height: 15px;
  border: 2.5px solid #f3efe9;
  border-radius: 50%;
  transition: transform .22s cubic-bezier(.2, .7, .2, 1);
}

.dot.up { background: #22a861; }
.dot.down { background: #d8343f; }

.app:hover .dot,
.app:focus-within .dot { transform: translate(5px, -6px) scale(1.1); }

.bubble-warn {
  color: var(--bad);
  font-weight: 650;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 6px;
}

.history-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.history-list {
  max-height: min(60vh, 520px);
  margin: 0;
  padding: 6px 22px 20px;
  overflow-y: auto;
  list-style: none;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid #efe8e1;
  font-size: 14px;
}

.history-list li:last-child { border-bottom: 0; }
.history-list p { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.history-list strong { color: var(--ink); font-weight: 650; }
.history-list time { flex: none; color: var(--slate); font-size: 12.5px; white-space: nowrap; }
.history-list .empty { color: var(--ink-2); }

.wide-dialog { width: min(560px, calc(100vw - 32px)); }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 132px;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

.open {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: inherit;
  text-decoration: none;
  border-radius: 18px;
}

.glyph {
  position: relative;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 30px;
  overflow: hidden;
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .35),
    0 12px 26px rgba(40, 24, 18, .16);
  transition: transform .22s cubic-bezier(.2, .7, .2, 1), box-shadow .22s ease;
}

.glyph svg,
.glyph img,
.bolt {
  position: relative;
  z-index: 1;
}

.glyph svg { width: 50px; height: 50px; }

.glyph img {
  display: block;
  width: 72%;
  height: 72%;
  object-fit: contain;
}

.glyph[data-fit="cover"] img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.glyph[data-icon="connect"] img { width: 86%; height: 86%; }

.bolt {
  font-size: 46px;
  line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(79, 139, 255, .4));
}

.glyph::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, 0) 46%);
  pointer-events: none;
}

.glyph[data-icon="coprod"] { background: #0f1115; }
.glyph[data-icon="connect"] { background: #101820; }
.glyph[data-icon="disparos"] { background: linear-gradient(135deg, #4f8bff, #9b5cff); }
.glyph[data-fit="cover"] { background: transparent; }

.name {
  margin-top: 12px;
  max-width: 116px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 620;
  letter-spacing: -0.015em;
  line-height: 1.25;
  text-align: center;
}

.bubble {
  display: grid;
  gap: 3px;
  width: 200px;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s cubic-bezier(.2, .7, .2, 1), max-height .22s ease, margin .22s ease;
}

.bubble-host {
  overflow: hidden;
  color: var(--slate);
  font-size: 11px;
  letter-spacing: .01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.app:hover,
.app:focus-within { z-index: 3; }

.app:hover .glyph,
.app:focus-within .glyph {
  transform: scale(1.1) translateY(-6px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .45),
    0 18px 34px rgba(40, 24, 18, .22);
}

.app:hover .bubble,
.app:focus-within .bubble {
  max-height: 8em;
  margin-top: 8px;
  opacity: 1;
  transform: none;
}

.edit {
  position: absolute;
  z-index: 5;
  top: -2px;
  left: calc(50% + 30px);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(40, 24, 18, .18);
  cursor: pointer;
  opacity: 0;
  transform: scale(.86);
  transition: opacity .16s ease, transform .16s ease;
}

.edit svg { width: 13px; height: 13px; }

.app:hover .edit,
.app:focus-within .edit {
  opacity: 1;
  transform: scale(1);
}

.add .glyph {
  background: rgba(255, 255, 255, .55);
  color: var(--ink);
  box-shadow: none;
  border: 1.5px dashed #cfc4bb;
}

.add .glyph::after { display: none; }

.add:hover .glyph,
.add:focus-visible .glyph {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(40, 24, 18, .08);
}

.status {
  margin: 0;
  color: var(--ink-2);
  text-align: center;
}

.status button {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font-weight: 650;
  cursor: pointer;
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent-grad);
  color: var(--on-accent);
  font-weight: 650;
  cursor: pointer;
}

.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .6; cursor: progress; }

.btn.quiet {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-2);
}

.btn.quiet:hover { filter: none; background: #f6f3ef; }

dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: var(--shadow-2);
}

dialog::backdrop { background: rgba(26, 22, 20, .46); }

form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

form h2 {
  margin: 0 0 2px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 650;
}

input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 450;
}

textarea { resize: vertical; min-height: 76px; }

input:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.form-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--bad);
  font-size: 14px;
}

.form-error:empty { display: none; }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-actions-end { display: flex; gap: 8px; margin-left: auto; }

.link-danger {
  padding: 8px 2px;
  border: 0;
  background: none;
  color: var(--bad);
  font-weight: 650;
  cursor: pointer;
}

.link-danger:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .top { padding-top: 20px; }
  .toolbar { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  .menu { width: 100%; justify-content: center; }
  .groups { gap: 30px; padding-bottom: 56px; }
  .library { gap: 28px 10px; }
  .history-list li { flex-direction: column; gap: 2px; }
  .form-row { grid-template-columns: 1fr; }
  .group.client .library { flex-wrap: wrap; }
  .group.client .app { width: 84px; }
  .group.client .glyph { width: 64px; height: 64px; border-radius: 19px; }
  .app { width: 104px; }
  .glyph { width: 86px; height: 86px; border-radius: 26px; }
  .glyph svg { width: 42px; height: 42px; }
  .bolt { font-size: 38px; }
  .name { font-size: 12.5px; }
  .bubble { width: 168px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions-end { margin-left: 0; }
  .form-actions-end .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .glyph, .bubble, .edit, .dot { transition: none; }
  body.arranging .app[data-id] .glyph { animation: none; }
  .app:hover .glyph,
  .app:focus-within .glyph { transform: none; }
}
