/* Central: ferramenta aberta dentro do Portal + dock (estilo Mac no computador, barra no celular) */
body.in-tool { overflow: hidden; }
body.in-tool .stage { visibility: hidden; }

.workspace {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #f3efe9;
}

.workspace[hidden] { display: none; }

.frames, .frame { position: absolute; inset: 0; }
.frame[hidden] { display: none; }

.frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.frame-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: #f3efe9;
  color: var(--ink-2);
  font-size: 15px;
  text-align: center;
  transition: opacity .25s ease;
}

.frame-loading p { margin: 0; max-width: 300px; }
.frame-loading .glyph { width: 76px; height: 76px; border-radius: 22px; animation: breathe 1.4s ease-in-out infinite; }
.frame-loading .glyph svg { width: 36px; height: 36px; }
.frame.loaded .frame-loading { opacity: 0; pointer-events: none; }

@keyframes breathe { 50% { transform: scale(.92); opacity: .8; } }

/* faixa na borda de baixo: encostou o mouse, a dock aparece */
.dock-zone {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  display: flex;
  justify-content: center;
}

.dock-handle {
  width: 64px;
  height: 4px;
  margin-top: 3px;
  border-radius: 4px;
  background: rgba(15, 17, 21, .28);
}

.dock {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 10px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: calc(100vw - 24px);
  padding: 7px 9px;
  border-radius: 22px;
  background: rgba(250, 247, 243, .74);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6), 0 18px 50px rgba(15, 17, 21, .28);
  transform: translate(-50%, calc(100% + 24px));
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}

.dock.shown { transform: translate(-50%, 0); }

.dock-apps, .dock-open { display: flex; align-items: flex-end; gap: 6px; }
.dock-open:empty { display: none; }
.dock-apps { min-width: 0; }

.dock-sep {
  align-self: center;
  flex: none;
  width: 1px;
  height: 34px;
  background: rgba(15, 17, 21, .14);
}

.dock-item {
  position: relative;
  display: grid;
  justify-items: center;
  flex: none;
  padding: 0 0 7px;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.dock-item[hidden] { display: none; }

.dock-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  transition: transform .18s cubic-bezier(.2, .7, .2, 1);
}

.dock-icon .glyph {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 4px 10px rgba(40, 24, 18, .18);
}

.dock-icon .glyph svg { width: 22px; height: 22px; }
.dock-icon .glyph .bolt { font-size: 22px; }
.dock-icon .glyph::after { display: none; }

.dock-item:hover .dock-icon,
.dock-item:focus-visible .dock-icon { transform: translateY(-7px) scale(1.12); }

.dock-home .dock-icon,
.dock-folder .dock-icon,
.dock-action .dock-icon {
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(40, 24, 18, .14);
}

.dock-home img { width: 24px; height: 26px; }
.dock-action svg { width: 20px; height: 20px; color: var(--ink-2); }
.dock-action .dock-icon { width: 38px; height: 38px; margin-bottom: 4px; }

.folder-grid {
  display: grid;
  grid-template-columns: repeat(2, 11px);
  gap: 4px;
}

.folder-grid i {
  width: 11px;
  height: 11px;
  border-radius: 3.5px;
  background: #2b2f38;
}

.folder-grid i:nth-child(2) { background: var(--accent); }
.folder-grid i:nth-child(3) { background: #e8d9c7; }
.folder-grid i:nth-child(4) { background: #ea4b71; }

.dock-folder[aria-expanded="true"] .dock-icon { box-shadow: 0 0 0 2px var(--accent), 0 4px 10px rgba(40, 24, 18, .14); }

/* pontinho embaixo = ferramenta aberta; tracinho = a que está na tela */
.dock-item.running::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink);
}

.dock-item.current::after { width: 14px; border-radius: 3px; background: var(--accent); }

/* seta = abre em nova aba */
.dock-item.external .dock-icon::after {
  content: "\2197";
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .22);
}

.dock-label {
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 10px);
  padding: 4px 9px;
  border-radius: 7px;
  background: rgba(15, 17, 21, .88);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .12s ease, transform .12s ease;
}

.dock-item:hover .dock-label,
.dock-item:focus-visible .dock-label { opacity: 1; transform: none; }

/* pasta: painel acima da dock, como as pastas da dock do Mac */
.folder-panel {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 92px;
  width: min(780px, calc(100vw - 24px));
  max-height: min(64vh, 620px);
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(250, 247, 243, .9);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6), 0 22px 60px rgba(15, 17, 21, .3);
  transform: translateX(-50%);
}

.folder-panel[hidden] { display: none; }

.folder-panel section {
  padding: 10px 10px 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .6);
}

.folder-panel h3 {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-2);
}

.folder-row { display: flex; flex-wrap: wrap; gap: 6px 9px; padding-top: 4px; }
.dock-item.external .dock-icon::after { z-index: 2; }

.dock-item.small .dock-icon,
.dock-item.small .dock-icon .glyph { width: 38px; height: 38px; border-radius: 11px; }
.dock-item.small .dock-icon .glyph svg { width: 18px; height: 18px; }
.dock-item.small .dock-label { bottom: calc(100% + 4px); }
.dock-item.small:hover .dock-icon { transform: scale(1.08); }

/* Ctrl+K */
.switcher {
  width: min(520px, calc(100vw - 24px));
  margin-top: 12vh;
  padding: 8px;
  border-radius: 16px;
}

.switcher input {
  height: 46px;
  border: 0;
  font-size: 17px;
}

.switcher input:focus { outline: none; }

.switcher-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.switcher-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.switcher-list li[aria-selected="true"],
.switcher-list li:hover { background: #f4eee8; }

.switcher-list .dock-icon,
.switcher-list .dock-icon .glyph { width: 32px; height: 32px; border-radius: 9px; }
.switcher-list .dock-icon .glyph svg { width: 16px; height: 16px; }
.switcher-name { font-weight: 620; }
.switcher-meta { color: var(--slate); font-size: 13px; }

/* Celular: barra fixa embaixo, a ferramenta ocupa o resto */
@media (max-width: 700px), (pointer: coarse) {
  .frames { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .dock-zone { display: none; }
  .dock {
    left: 0;
    right: 0;
    bottom: 0;
    justify-content: space-around;
    max-width: none;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    border-radius: 0;
    transform: none;
  }
  .dock.shown { transform: none; }
  .dock-item:hover .dock-icon { transform: none; }
  .dock-label { display: none; }
  .dock-icon, .dock-icon .glyph { width: 42px; height: 42px; }
  .dock-sep { display: none; }
  .dock-apps { overflow-x: auto; scrollbar-width: none; }
  .folder-panel {
    left: 0;
    bottom: calc(64px + env(safe-area-inset-bottom));
    width: 100%;
    max-height: 70vh;
    grid-template-columns: 1fr;
    border-radius: 20px 20px 0 0;
    transform: none;
  }
  .switcher { margin-top: 6vh; }
}

@media (prefers-reduced-motion: reduce) {
  .dock, .dock-icon, .frame-loading { transition: none; }
  .frame-loading .glyph { animation: none; }
}
